//
//  loanSuccessView.m
//
//
//  Created by gynjobs on 2017/8/14.
//  Copyright © 2017年 gynjobs. All rights reserved.
//

#import "loanSuccessView.h"

@implementation loanSuccessView


-(instancetype)init{
    
    if(self = [super init]){
        
        self.backgroundColor = [UIColor colorWithString:UI_COLOR_MAIN_BG_1];
        [self initProcessView];
        [self initTipView];
        [self initFinishBtn];
    }
    
    [self updateConstraintsIfNeeded];
    return self;
    
}

-(void)updateConstraints{
    [super updateConstraints];
    
    [self.processView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.top.equalTo(self);
        make.height.mas_equalTo(LOAN_PROCESS_VIEW_HEIGHT);
        
    }];
    
    [self.tipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.processView.mas_bottom).with.offset(TIP_IMAGEVIEW_TOP);
        make.centerX.equalTo(self.mas_centerX);
        make.width.mas_equalTo(TIP_IMAGEVIEW_WIDTH);
        make.height.mas_equalTo(TIP_IMAGEVIEW_HEIGHT);
        
    }];
    
    [self.tipLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.tipImageView.mas_bottom).with.offset(TIP_LABEL1_TOP);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.tipLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.tipLabel1.mas_bottom).with.offset(TIP_LABEL2_TOP);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.finishBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.mas_bottom).with.offset(-BOTTOM_SPACE);
        make.left.equalTo(self.mas_left).with.offset(LEFT_RIGHT_SPACE);
        make.right.equalTo(self.mas_right).with.offset(-LEFT_RIGHT_SPACE);
        make.height.mas_equalTo(FINISH_BTN_HEIGHT);
    }];
    
    
}


#pragma mark -
#pragma mark init subview

-(void)initProcessView{
    self.processView = [[LoanProcessView alloc] init];
    [self addSubview:self.processView];
}

-(void)initTipView{
    
    self.tipImageView = [[UIImageView alloc] init];
    self.tipImageView.image = [UIImage imageNamed:UI_IMAGE_HOME_LOAN_APPLYLOAN_SUCCESS];
    
    
    self.tipLabel1 = [[UILabel alloc] init];
    self.tipLabel2 = [[UILabel alloc] init];
    self.tipLabel1.text = @"申请成功";
    self.tipLabel2.text = @"我们会为您推荐最适合贷款产品\n请耐心等待";
    self.tipLabel2.numberOfLines = 0;
    self.tipLabel2.textAlignment = NSTextAlignmentCenter;
   self.tipLabel1.font = [UIFont systemFontOfSize:UI_FOND_TAB_CREDIT_CELL_MAIN_1];
    self.tipLabel2.font = [UIFont systemFontOfSize:UI_FOND_TAB_CREDIT_CELL_SUB_1];
    self.tipLabel1.textColor = [UIColor colorWithString:UI_COLOR_COMMON_TEXT_COLOR_2];
    self.tipLabel2.textColor = [UIColor colorWithString:UI_COLOR_COMMON_TEXT_COLOR_3];
    
    
    
    [self addSubview:self.tipImageView];
    [self addSubview:self.tipLabel1];
    [self addSubview:self.tipLabel2];
    
}

-(void)initFinishBtn{
    
    self.finishBtn = [[UIButton alloc] init];
    self.finishBtn.layer.cornerRadius = VIEW_RADIUS;
    [self.finishBtn setBackgroundColor:[UIColor colorWithString:UI_COLOR_MAIN_BG_3]];
    [self.finishBtn setTitle:@"完成" forState:UIControlStateNormal];
    [self.finishBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self addSubview:self.finishBtn];
    
}



@end
